<template>
    <div class="login-wrap">
        <div class="ms-login">
            <div class="ms-title">用户登录</div>
            <div class="ms-titles">WELCOM TO THE SYSTEM</div>
            <el-form :model="param" :rules="rules" ref="login" label-width="0px" class="ms-content">
                <el-form-item prop="username">
                    <el-input class="itxt" size="large" v-model="param.userName" placeholder="用户名">
                    </el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input size="large" class="itxt" type="password" placeholder="密码" v-model="param.password"
                        @keyup.enter.native="submitForm()">
                    </el-input>
                </el-form-item>
                <div class="login-btn">
                    <el-button size="large" type="primary" @click="submitForm()">登录</el-button>
                </div>
            </el-form>
        </div>
    </div>
</template>

<script>
import { login } from '../../api/index';
export default {
    data: function () {
        return {
            param: {
                userName: '',
                password: ''
            },
            rules: {
                username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
                password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
            },
            userlist: [
                {
                    userName: "admin",
                    password: "admin123"
                }
            ]
        };
    },
    methods: {
        submitForm() {
            this.$message.success('登录成功');
                    localStorage.setItem('ms_username', 'admin');
                    this.$router.push({
                        path: 'test'
                    });
            // login(this.param).then(e => {
            //     if (e.code == 200) {
            //         this.$message.success('登录成功');
            //         localStorage.setItem('ms_username', e.data.userName);
            //         console.log(e);
            //         this.$router.push({
            //             path: 'sucaiku'
            //         });
            //         // setTimeout(function() {
            //         //     window.location.reload();
            //         // }, 500);
            //     } else {
            //         this.$message.error(e.msg);
            //         return false;
            //     }
            // });
        }
    }
};
</script>

<style scoped>
.login-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: url(../../assets/img/login-bg.jpg);
    background-size: 100%;
}

.ms-title {
    width: 100%;
    margin-top: 15%;
    margin-bottom: 8%;
    line-height: 50px;
    text-align: center;
    font-size: 30px;
    font-weight: bold;
    color: #3e83e9;
}

.ms-titles {
    width: 100%;
    line-height: 10%;
    text-align: center;
    font-size: 11px;
    color: #222222;
}

.ms-login {
    position: absolute;
    margin-left: 50%;
    margin-top: 12%;
    width: 23%;
    height: 62%;
    border-radius: 5px;
    background: rgba(255, 255, 255, 1);
    overflow: hidden;
}

.ms-content {
    padding: 30px 30px;
}

.itxt {
    text-align: center;
    font-size: 20px;
}

.login-btn {
    text-align: center;
    margin-top: 25%;
    width: 100%;
    margin-bottom: 30%;
}

.login-btn button {
    width: 100%;
    height: 25%;
    font-size: 20px;
    margin-bottom: 30%;
}

.login-tips {
    font-size: 12px;
    line-height: 30px;
    color: #fff;
}
</style>